define(['./controllers'], function (controllers) {
    'use strict';
    controllers.controller('indexCtrl', ['$scope', '$timeout', '$state','$rootScope','$cookieStore','$modal',
        function ($scope,$timeout, $state,$rootScope,$cookieStore,$modal) {
            //打开上传mode
            $scope.openMessage = function (title,info,goPath) {
                var modalInstance = $modal.open({
                    templateUrl: 'partials/modal/message.html',
                    controller: 'messageCtrl',
                    size: 'sm',
                    resolve: {
                        title: function () {
                            return title;
                        },
                        info:function(){
                            return info;
                        }
                    }
                });
                //操作返回
                modalInstance.result.then(function (selectedItem) {
                    // 清空用户本地token存储的信息，如果
                    $rootScope.user = null;
                    $state.go(goPath);//跳转到登录界面
                    return;
                }, function () {
                    $state.go(goPath);//跳转到登录界面
                    return;
                });
            };
            $rootScope.$on('userIntercepted',function(errorType){
                console.log(errorType)
                $scope.openMessage("提示信息","登录超时请重新登录","login");
            });

        }
    ])

});
